package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Art_author;
import com.hbnu.system.service.IArtauthorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@Api(tags = "艺体类作者信息")
@RestController
@RequestMapping("/art_author")
public class Art_authorController {

    @Autowired
    IArtauthorService iArtauthorService;

    @ApiOperation("新增专利作者")
    @PostMapping("/addArtAuthor")
    public Rest<String> addArtAuthor(@RequestBody Art_author artauthor){
        boolean ba = iArtauthorService.addArtAuthor(artauthor);
        return ba ? Rest.success() : Rest.failed();
    }

    @ApiOperation("删除专利作者信息")
    @GetMapping("/deleteArtAuthor")
    public Rest<String> deleteArtAuthor(String id){
        boolean ba1 = iArtauthorService.deleteArtAuthor(id);
        return ba1 ? Rest.success():Rest.failed();
    }

    @ApiOperation("修改专利作者信息")
    @PostMapping("/updateArtAuthor")
    public Rest<String> updateArtAuthor(@RequestBody Art_author artauthor){
        boolean ba2 = iArtauthorService.updateArtAuthor(artauthor);
        return ba2 ? Rest.success():Rest.failed();
    }

    @ApiOperation("根据专利编号搜索作者信息")
    @GetMapping("/selectAllAuthor")
    public Rest<List<Art_author>> selectAllAuthor(String id){
        List<Art_author> list = iArtauthorService.listAuthor(id);
        return Rest.success(list,list.size());
    }


}

